package com.dongway.netcondition.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dongway.core.web.AbstractBaseController;
import com.dongway.netcondition.dto.AutoCompleteItem;
import com.dongway.netcondition.service.DevNetStateService;
import com.dongway.netcondition.service.DevSelectHelper;

@Controller
public class CommonController extends AbstractBaseController {

    @Autowired
    private DevSelectHelper selectHelper;
    @Autowired
    private DevNetStateService stateService;


    @RequestMapping("/road.json")
    @ResponseBody
    public Object getRoad(Integer branchId) {
        try {
            List<AutoCompleteItem> roads = selectHelper.getRoadListByBranchId(branchId);
            return JsonSuccess(roads);
        } catch (Exception e) {
            logger.error("获取路段错误", e);
            return JsonFailed(e);
        }
    }


    @RequestMapping("/station.json")
    @ResponseBody
    public Object getStation(Integer id) {
        try {
            List<AutoCompleteItem> stations = selectHelper.getStationListByRoadId(id);
            return JsonSuccess(stations);
        } catch (Exception e) {
            logger.error("获取收费站列表错误", e);
            return JsonFailed(e);
        }
    }

}
